package com.example.erp.mapper.system;

import com.example.erp.dto.systemDTO.MenuDTO;
import com.example.erp.pojo.system.Menu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 列表全部查询,状态为1
 * */
@Mapper
public interface MenuMapper {
    @Select("SELECT * FROM erp_menu WHERE status = 1")
    List<Menu> listAll();

    List<Menu> list(MenuDTO menuDTO);

    @Select("SELECT * FROM erp_menu WHERE menu_name = #{name}")
    Menu getByName(String name);

    @Select("SELECT * FROM erp_menu WHERE id != #{id} AND menu_name = #{name}")
    Menu getByIdName(@Param("id") Long id,@Param("name") String name);

    Integer add(Menu menu);

    Integer edit(Menu menu);

    @Delete("DELETE FROM erp_menu WHERE id = #{id}")
    Integer remove(Long id);

    @Select("SELECT menu_id FROM erp_menu")
    List<Long> getAllRouters();

    List<Menu> getRouters(List<Long> ids);

    List<Menu> getPermissions(List<Long> ids);
}
